//
//  ShakeViewController.m
//  KCZ_B段项目
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 Sky. All rights reserved.
//

#import "ShakeViewController.h"
#import <AudioToolbox/AudioToolbox.h>
#import "ZJHShakeDetailViewController.h"
#import "FitHeader.h"
#import "FontSizeSingleTon.h"
#define Font [[FontSizeSingleTon shareFontSize]array]
#import "Adaptive.h"
@interface ShakeViewController ()

@end

@implementation ShakeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
//    self.navigationController.navigationBar.translucent = NO;
    self.title = @"摇一摇";
#pragma mark 设置摇动
    [[UIApplication sharedApplication]setApplicationSupportsShakeToEdit:YES];
//    [self becomeFirstResponder];
}
-(void)loadView
{
    [super loadView];
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake((SCREENWIDTH - 100 * wt) / 2.0, 100 * ht, 100 * wt, 100 * ht)];
    imageView.contentMode = UIViewContentModeScaleToFill;
    imageView.image = [UIImage imageNamed:@"yaoyiyao"];
    [self.view addSubview:imageView];
    
    NSString *text = @"不知道吃啥摇一摇";
    CGFloat width = [Adaptive adaptiveWidthByString:text Height:30 * ht FontSize:20 * wt];
    UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake((SCREENWIDTH - width) / 2.0, imageView.frame.origin.y + imageView.frame.size.height + 80 * ht, width, 30 * ht)];
    lable.text = text;
    lable.textColor = [UIColor colorWithRed:0.19 green:0.75 blue:0.6 alpha:1];
    lable.font = [UIFont systemFontOfSize:20 * wt];
    [self.view addSubview:lable];
    
}
#pragma mark 摇一摇震动
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"shake"]) {
        
        AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
    }
}
#pragma mark 摇动结束
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    ZJHShakeDetailViewController *shakeDetailVC = [[ZJHShakeDetailViewController alloc]init];
    [shakeDetailVC setHidesBottomBarWhenPushed:YES];
    [self.navigationController pushViewController:shakeDetailVC animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
